package org.itboys.admin;

import javax.servlet.MultipartConfigElement;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.embedded.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.HashSet;
import java.util.Set;


/*import com.mangofactory.swagger.configuration.SpringSwaggerConfig;
import com.mangofactory.swagger.plugin.EnableSwagger;*/

/*@EnableSwagger*/
@Configuration
@ComponentScan
@EnableAutoConfiguration 
public class AdminApplication extends WebMvcConfigurerAdapter{


/*	 private SpringSwaggerConfig springSwaggerConfig;*/

	 public static void main(String[] args) {  
		    // -Dserver.port=$PORT 指定启动的 端口 右键 Run as 或 Debug as 的 Run Configuration
		    // 或 Debug Configuration 的Arguments 的 vm arguments可修改启动端口
		    // 可以这样加上 java -Dserver.port=8080 -Dprofile-name=real -Xms128m -Xmx128m -XX:PermSize=64m -Xss256k -XX:+DisableExplicitGC -XX:+UseParNewGC -XX:+UseCMSCompactAtFullCollection -XX:-CMSParallelRemarkEnabled -XX:+PrintGCTimeStamps -XX:+PrintGCDetails
	        SpringApplication app = new SpringApplication(AdminApplication.class);
	        app.setWebEnvironment(true);
	        app.setShowBanner(false);
	        Set<Object> set = new HashSet<Object>();
	        set.add("applicationContext.xml");
	        app.setSources(set);
	        app.run(args);
	 }  
	 
	 @Bean
	    MultipartConfigElement multipartConfigElement() {
	        MultipartConfigFactory factory = new MultipartConfigFactory();
	        factory.setMaxFileSize("40960KB");
	        factory.setMaxRequestSize("40960KB");
	        return factory.createMultipartConfig();
	    }
	 
    /*@Autowired
    public void setSpringSwaggerConfig(SpringSwaggerConfig springSwaggerConfig) {
        this.springSwaggerConfig = springSwaggerConfig;
    }
    
    @Bean
    public SwaggerSpringMvcPlugin customImplementation() {
        return new SwaggerSpringMvcPlugin(this.springSwaggerConfig).apiInfo(apiInfo()).includePatterns(".*?");
    }

    private ApiInfo apiInfo() {
        ApiInfo apiInfo = new ApiInfo(
                "admin.warmhome.com",
                "",
                "",
                "itboys",
                "",
                "");

        return apiInfo;
    }*/
	 
	 /*@Bean
	    CommonsMultipartResolver multipartResolver(){
	        return new CommonsMultipartResolver();
	    }*/
	 
}
